package services

import (
	"gitee.com/pangxianfei/simple"
	"tmaic/app/model"
	"tmaic/app/repositories"
)

var TestService = newTestService()

func newTestService() *testService {
	return &testService{}
}

type testService struct {
}

func (s *testService) Get(id int64) *model.Test {
	return repositories.TestRepository.Get(simple.DB(), id)
}

func (s *testService) Take(where ...interface{}) *model.Test {
	return repositories.TestRepository.Take(simple.DB(), where...)
}

func (s *testService) Find(cnd *simple.SqlCnd) []model.Test {
	return repositories.TestRepository.Find(simple.DB(), cnd)
}

func (s *testService) FindOne(cnd *simple.SqlCnd) *model.Test {
	return repositories.TestRepository.FindOne(simple.DB(), cnd)
}

func (s *testService) FindPageByParams(params *simple.QueryParams) (list []model.Test, paging *simple.Paging) {
	return repositories.TestRepository.FindPageByParams(simple.DB(), params)
}

func (s *testService) FindPageByCnd(cnd *simple.SqlCnd) (list []model.Test, paging *simple.Paging) {
	return repositories.TestRepository.FindPageByCnd(simple.DB(), cnd)
}

func (s *testService) Count(cnd *simple.SqlCnd) int64 {
	return repositories.TestRepository.Count(simple.DB(), cnd)
}

func (s *testService) Create(t *model.Test) error {
	return repositories.TestRepository.Create(simple.DB(), t)
}

func (s *testService) Update(t *model.Test) error {
	return repositories.TestRepository.Update(simple.DB(), t)
}

func (s *testService) Updates(id int64, columns map[string]interface{}) error {
	return repositories.TestRepository.Updates(simple.DB(), id, columns)
}

func (s *testService) UpdateColumn(id int64, name string, value interface{}) error {
	return repositories.TestRepository.UpdateColumn(simple.DB(), id, name, value)
}

func (s *testService) Delete(id int64) {
	repositories.TestRepository.Delete(simple.DB(), id)
}
